<?php

function commpage($db, $where, $order, $limit)
{
    $count = $db->where($where)->count();
    $Page = new \Think\Page($count, $limit);
    $show = $Page->show();
    $list = $db->where($where)->order($order)->limit($Page->firstRow . ',' . $Page->listRows)->select();
    $reault = array("data" => $list, "page" => $show);
    return $reault;
}

function getPreName($id)
{
    $preftype = M("preftype");
    $data = $preftype->find($id);
    return $data["pre_name"];
}

function getStaffName($id)
{
    $salestaff = M("salestaff");
    $data = $salestaff->find($id);
    return $data["ssa_name"];
}

function getDisName($id)
{
    $saletype = M("saletype");
    $data = $saletype->where("sat_para=" . $id)->find();
    return $data["sat_name"];
}

function getUserName($id)
{
    $db = M("users", "yub_", C("CONN_YYB"));
    $data = $db->find($id);
    return $data["uss_nickname"];
}

function getAgentName($id)
{
    $db = M("saleagent");
    $data = $db->find($id);
    return $data["sag_name"] == null ? "无" : $data["sag_name"];
}
